/*
 * Created: Author: Aléx Carvalho / Date: Jan 23, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-06-12 03:38:01 +0000 (Fri, 12 Jun 2015) $
 */

package com.cpm.context;

import com.cpm.aggregate.SessionAttribute;
import com.cpm.wrapper.AttributeMap;
import com.cpm.wrapper.SolidObjects;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;

@SessionScoped
public class SessionContext implements Serializable {
    private static final long serialVersionUID = 1L;

    private final AttributeMap<SessionAttribute, Object> attributes = new AttributeMap<>();

    public SessionContext() {
    }
    
    public void putAttribute(SessionAttribute key, Object value) {
        SolidObjects.notNullValues(key, value);
        attributes.putAttribute(key, value);
    }
    
    public <RESULT> RESULT getAttribute(SessionAttribute key) {
        return (RESULT) attributes.getAttribute(SolidObjects.notNull(key));
    }
    
    public void removeAttribute(SessionAttribute key) {
        SolidObjects.notNull(key);
        attributes.removeAttribute(key);
    }
}
